const http = uni.$u.http

// 获取广告轮播图
export const getpolyesteryarn = data => http.get('/polyesteryarn')

// 获取动态列表
export const getFeeds = data => http.get('/feeds', {
	params: data
})
// 获取指定 id 动态详情
export const getFeedInfo = data => http.get('/feeds/' + data.id)
// 获取指定 ID 动态 评论详情
export const getFeedComments = data => http.get('/feeds/' + data.id + '/comments')
// 删除指定 ID 的动态
export const deleteFeed = data => http.delete('/feeds/' + data.id + '/currency')
// 点赞动态
export const likeThisFeed = data => http.post('/feeds/' + data.id + '/like')
// 取消点赞动态
export const unlikeThisFeed = data => http.delete('/feeds/' + data.id + '/unlike')
// 发布一条动态
export const postOneFeed = data => http.post('/feeds', data)
// 评论一条动态
export const commentOneFeed = data => http.post('/feeds/' + data.id + '/comments', {
	body: data.body
})

// 获取资讯列表信息
export const getNews = data => http.get('/news', {
	params: data,
})



// 文件上传操作
export const uploadFile = async file => {
	let rfile = file
	// #ifdef MP-WEIXIN
	rfile = uni.getFileSystemManager().readFileSync(file.path)
	// #endif

	// 将文件写入后台系统系统
	let ufile = await uni.uploadFile({
		url: 'http://ts.lagou.uieee.com/api/v2/files',
		header: {
			Authorization: "Bearer " + uni.getStorageSync("token"),
		},
		name: 'file',
		file: rfile,
		filePath: file.path
	});
	console.log(JSON.parse(ufile[1].data))
	return JSON.parse(ufile[1].data)
}